<template>
  <div>
    <nav-bar>
      <div slot="left">
        <div class="backImages" @click="backClicks">
          <img src="~assets/images/Detail/Detail.png" alt="">
        </div>
      </div>
      <div slot="center" class="title">
        <div v-for="(item,index) in itemCenter" class="item-title" :class="{isActive: currentIndex === index}" @click="titleClick(index)">
          {{item}}
        </div>
      </div>
    </nav-bar>
  </div>
</template>

<script>
  import NavBar from "components/common/navbar/NavBar";

  export default {
    name: "DetailNarBar",
    components:{
      NavBar,
    },
    props:{
      itemCenter:{
        type: Array,
        default(){
          return [];
        }
      }
    },
    data(){
      return {
        currentIndex: 0,
      };
    },
    methods:{
      titleClick(index){
        this.currentIndex = index;
        this.$emit("itemClick",index)
      },
      backClicks(){
        this.$router.back();
      }
    }
  }
</script>

<style scoped>
  .title{
    display: flex;
    text-align: center;
    font-size: 13px;
  }
  .item-title{
    flex: 1;
  }
  .isActive{
    color: var(--color-high-text);
  }
  .backImages{
    margin: 0 auto;
  }
  .backImages>img{
    width: 20px;
    height: 20px;
    margin-top: 14px;
  }
</style>
